import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { ConnectMysqlService } from './connect-mysql.service';
import { CreateConnectMysqlDto } from './dto/create-connect-mysql.dto';
import { UpdateConnectMysqlDto } from './dto/update-connect-mysql.dto';

@Controller('connect-mysql')
export class ConnectMysqlController {
  constructor(private readonly connectMysqlService: ConnectMysqlService) {}

  // 查
  @Get()
  findOne(@Query() query: { keyword: string; page: number; pageSize: number }) {
    return this.connectMysqlService.detect(query);
  }

  // 改
  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateConnectMysqlDto: UpdateConnectMysqlDto,
  ) {
    return this.connectMysqlService.update(+id, updateConnectMysqlDto);
  }

  // 删
  @Delete(':id')
  remove(@Param('id') id: number) {
    return this.connectMysqlService.remove(+id);
  }

  // 增
  @Post()
  create(@Body() createConnectMysqlDto: CreateConnectMysqlDto) {
    return this.connectMysqlService.create(createConnectMysqlDto);
  }
}
